<script lang="ts">
import ComSearch from "./ComSearch/index.vue";
import ComBanner from "./ComBanner/index.vue";
import ComNavbar from "./ComNavbar/index.vue";
import ComSinge  from "./ComSingle/index.vue";
import ComTitle  from "./ComTitle/index.vue";
import ComWindow from "./ComWindow/index.vue";
import ComProduct from "./ComProduct/index.vue";
import ComNone from "./ComNone/index.vue"

import { h } from "vue";

const components = {
	"com-search": ComSearch,
	"com-banner": ComBanner,
  "com-none": ComNone,
	"com-navbar": ComNavbar,
	"com-imagesingle": ComSinge,
	"com-title": ComTitle,
	"com-window": ComWindow,
	"com-product": ComProduct,
};

export default {
	props: {
		/* ... */
		list: {
			type: Array<{
				group: string;
				name: string;
				id: string;
				params: any;
				type: string;
				style: any;
			}>,
			default: [
				{
					name: "搜索框",
					type: "search",
					group: "shop",
					params: {
						placeholder: "请输入关键字进行搜索",
					},
					style: {
						textAlign: "6",
						searchStyle: "9",
					},
					id: "n50214144672381",
				},
				{
          name: "无数据",
					type: "none",
					group: "null",
					params: {
						text: "暂无数据",
					},
					style: {},
					id: "",
				},
			],
		},
	},
	setup(props) {
		return () =>
			h(
				"view",
				{
					class: "w-full",
				},
				// "列表"
				props.list.map((item) => {
          const dom = components[`com-${item.type.toLowerCase()}`] ?? null
					if (dom) return h(dom, {
						config: item,
					});
				})
			);
	},
};
</script>
